package com.yiyuan.app.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.guaike.core.entity.enums.EnableStatusEnum;
import com.guaike.core.mybatis.plugins.BaseDAO;
import com.yiyuan.app.entity.enums.PackageTypeEnum;
import com.yiyuan.app.entity.po.MProductPackagePO;
import com.yiyuan.app.mapper.MProductPackageMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class MProductPackageDAO extends BaseDAO<MProductPackageMapper, MProductPackagePO> {

    public MProductPackagePO findNewPersonPackage() {
        LambdaQueryWrapper<MProductPackagePO> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MProductPackagePO::getProductType, PackageTypeEnum.new_person_package.getCode());
        wrapper.eq(MProductPackagePO::getStatus, EnableStatusEnum.ENABLE.getCode());
        return getBaseMapper().selectOne(wrapper);
    }

    public MProductPackagePO findActivityPackage() {
        LambdaQueryWrapper<MProductPackagePO> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MProductPackagePO::getProductType, PackageTypeEnum.activity_package.getCode());
        wrapper.eq(MProductPackagePO::getStatus, EnableStatusEnum.ENABLE.getCode());
        return getBaseMapper().selectOne(wrapper);
    }

    public List<MProductPackagePO> findRechargeActivity() {
        LambdaQueryWrapper<MProductPackagePO> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MProductPackagePO::getProductType, PackageTypeEnum.recharge_activity.getCode());
        wrapper.eq(MProductPackagePO::getStatus, EnableStatusEnum.ENABLE.getCode());
        wrapper.orderByAsc(MProductPackagePO::getMoney);
        return getBaseMapper().selectList(wrapper);
    }
}
